package cn.wit.front.controller;

import cn.wit.front.condition.SearchRecruitInfoCondition;
import cn.wit.front.service.RecruitInfoService;
import cn.wit.utils.pojo.RecruitInfo;
import cn.wit.utils.response.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/job/recruitInfo")
@CrossOrigin
@Api(tags = "招聘信息")
public class RecruitInfoController {
    private Logger logger = LoggerFactory.getLogger(RecruitInfoController.class);

    @Autowired
    private RecruitInfoService recruitInfoService;


    @GetMapping("/searchRecruitInfo/{num}/{size}")
    @ApiOperation("分页条件查询招聘信息")
    public Result searchRecruitInfo(@PathVariable("num") int num,
                                    @PathVariable("size") int size, SearchRecruitInfoCondition condition){
        IPage<RecruitInfo> page=new Page<>(num,size);
        try{
            return this.recruitInfoService.searchPage(page, condition);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return Result.build(500,"error");
    }
}
